from lxml import etree
class MetaLink(object):
    def __init__(self, data):
        self.root = etree.XML(data)
     
    def get_urls(self):
        urls = []
        for fileselement in self.root:
            for fileelement in fileselement:
                #print fileelement.get('name')
                for url in fileelement.iter('{http://www.metalinker.org/}url'):
                    if url.get('type') != "http":
                        continue
                    # protocol="ftp" type="ftp" location="NL" preference="53", text is the actual url
                    #logger.debug('Metalink file %s' % url.text) 
                    urls.append(url.text)
        return urls
        
    def __str__(self):
        pass
